﻿#region Using Directives

    using System;
    using System.Xml.Linq;

    using Csla;

    using MarketPulse.BusinessLogic.Core;
    using MarketPulse.BusinessLogic.Common.Criteria;

#endregion

namespace MarketPulse.BusinessLogic.Common
{
    /// <summary>
    /// This class represents a read only instance of an EnquiryReason within the system.
    /// </summary>
    [Serializable]
    [Csla.Server.ObjectFactory("MarketPulse.DataAccess.Factory.EnquiryFactory, MarketPulse.DataAccess.Factory", "FetchReasonInfo")]
    public class EnquiryReasonInfo : MarketPulseReadOnlyBase<EnquiryReasonInfo>
    {

        #region Member Varaiables

            /// <summary>
            /// The GUID of the EnquiryType (BusinessObject) associated with this EnquiryReason
            /// </summary>
            public static PropertyInfo<Nullable<Guid>> mEnquiryTypeGUIDProperty = RegisterProperty<Nullable<Guid>>(p => p.EnquiryTypeGUID);

            /// <summary>
            /// The GUID of the Company (BusinessObject) associated with this EnquiryReason
            /// </summary>
            public static PropertyInfo<Nullable<Guid>> mCompanyGUIDProperty = RegisterProperty<Nullable<Guid>>(p => p.CompanyGUID);

            /// <summary>
            /// A human readable label for this EnquiryReason
            /// </summary>
            public static PropertyInfo<XElement> mLabelProperty = RegisterProperty<XElement>(p => p.Label);

            /// <summary>
            /// Additional info text to go with the EnquiryReason
            /// </summary>
            public static PropertyInfo<XElement> mAdditionalInfoTextProperty = RegisterProperty<XElement>(p => p.AdditionalInfoText);

        #endregion

        #region Constructors

            /// <summary>
            /// Default constructor is private in order to (try to) enforce construction
            /// only via the static factory methods provided.
            /// </summary>
            private EnquiryReasonInfo()
            {
            }

        #endregion

        #region Methods

            #region Factory Methods

                /// <summary>
                /// Method used to retrieve a EnquiryReasonInfo object 
                /// </summary>
                /// <param name="enquiryReasonGuid">The guid of the EnquiryReason that relates to this object to retrieve</param>
                /// <returns>The populated EnquiryReasonInfo object</returns>
                public static EnquiryReasonInfo GetByGuid(Guid enquiryReasonGuid)
                {
                    return DataPortal.Fetch<EnquiryReasonInfo>(new SingleCriteria<Guid>(enquiryReasonGuid));
                }

            #endregion

        #endregion

        #region Properties

            #region Association GUID Properties (Foreign Keys)

                /// <summary>
                /// The GUID of the EnquiryType (BusinessObject) associated with this EnquiryReason
                /// </summary>
                public Nullable<Guid> EnquiryTypeGUID { get { return GetProperty(mEnquiryTypeGUIDProperty); } }

                /// <summary>
                /// The GUID of the Company (BusinessObject) associated with this EnquiryReason
                /// </summary>
                public Nullable<Guid> CompanyGUID { get { return GetProperty(mCompanyGUIDProperty); } }

            #endregion

            /// <summary>
            /// A human readable label for this EnquiryReason
            /// </summary>
            public XElement Label { get { return GetProperty(mLabelProperty); } }

            /// <summary>
            /// Additional info text to go with the EnquiryReason
            /// </summary>
            public XElement AdditionalInfoText { get { return GetProperty(mAdditionalInfoTextProperty); } }

        #endregion       
    }
}
